﻿using System;
using System.Windows.Data;

namespace JY.Wpf.Core.Converters
{
    /// <summary>
    /// bool转换是否转换器
    /// </summary>
    public class BooleanToYesNoConverter : IValueConverter
    {
        /// <summary>
        /// 转换
        /// </summary>
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            string result = "否";

            if (value == null)
            {
                result= "--";
            }
            else if ((bool)value)
            {
                result = "是";
            }
            else if (!(bool)value)
            {
                result = "否";
            }

            return result;
        }
        /// <summary>
        /// 回调
        /// </summary>
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return value;
        }
    }
}
